﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Data.Linq;
using System.Text;
using NUnit.Framework;
using Groupware;
using GeoRef;

namespace GroupWareUnitTests
{
    [TestFixture]
    public class TripTests
    {
        private Hashtable hash;
        [SetUp]
        public void setUp()
        {
            hash = new Hashtable();
        }


        /// <summary>
        /// 
        /// </summary>
        [Test]
        public void CreateTripTests()
        {
            /*hash.Add("UserID", 2);
            hash.Add("DepartureDate", new DateTime(2008, 05, 03));
            hash.Add("Departure", "Pisa");
            hash.Add("Arrival", "Livorno");
            hash.Add("EstimatedTime", 20);
            hash.Add("Note", "Che viaggio");
            GeoRef.GeoLoc g1 = new GeoRef.GeoLoc(40.0, 39.0, "Via Buonarroti pisa", "casa mia");
            GeoRef.GeoLoc g2 = new GeoRef.GeoLoc(41.0, 39.0, "Via Pratale pisa", "vicino casa mia");
            hash.Add("GeoTrip", new GeoRef.GeoTrip(g1, g2));
            int tid = TripManager.CreateTrip(hash);
            Trip t = TripManager.GetTripById(tid);
            Assert.IsNotNull(t.Id);
            */
        }

        [Test]
        public void enumerators()
        {
            hash.Add("aaa", "bbb");
            hash.Add("aaba", "bbb");
            hash.Add("aaab", "bbb");
            IDictionaryEnumerator d = hash.GetEnumerator();
            int count = 0;
            while (d.MoveNext())
            {
                Console.WriteLine("KEY " + d.Key + ": VALUE " + d.Value);
                count++;
            }
            Assert.AreEqual(count, hash.Count);
        }

        [Test]
        public void notification()
        {/*
            String[] ss = new String[3];
            ss[0] = "Ciao";
            ss[1] = "oaiC";
            ss[2] = "Bye";
            hash.Add("utenti", ss);
            hash.Add("nome", "LOA");
            Notification n = new Notification(Notification.TEMP_NOTIFICATION);
            Console.WriteLine(Notification.path);
            String s = n.getNotification(hash);
            Console.WriteLine(s);
            Assert.AreEqual(s, "La lista LOA verra' recapitata agli utenti Ciao, oaiC, Bye");
            hash = new Hashtable();
            hash.Add("origin", "");
            n = new Notification("new");
            n.isValidHash(ref hash);
            Assert.IsNotNull(hash["uname"]);
            Assert.IsNotNull(hash["origin"]);
          * */
        }


        [Test]
        public void typeofs()
        {
            hash.Add("aaa", "Ciao");
            hash.Add("aaba", new String[3]);
            hash.Add("aaab", 3);
            IDictionaryEnumerator d = hash.GetEnumerator();
            Assert.AreEqual(hash["aaa"].GetType(), typeof(String));
            while (d.MoveNext())
            {
                if (d.Value.GetType().Equals(typeof(String)))
                    Console.WriteLine("Stringa");
                else if (d.Value.GetType().Equals(typeof(String[])))
                    Console.WriteLine("Array Stringhe");
                else Console.WriteLine("Errore");
            }
        }

        public static void Main()
        { }
    }
}
